/*
 * Created on Apr 8, 2005
 */
package org.vectrics.skill;

import java.util.HashSet;
import java.util.Set;

import org.vectrics.SystemException;
import org.vectrics.common.db.CodedObject;
import org.vectrics.common.db.Voidable;

/**
 * @author mmoore
 */
public class SkillScoringMethod implements CodedObject, Voidable  {
	public static String SCORING_METHOD_YES_NO = "yes-no";
	public static String SCORING_METHOD_LEVEL = "level";
	public static String SCORING_METHOD_NONE = "none";

	private String code = null;
	private String description = null;
	private boolean voided = false;

	public SkillScoringMethod() {
		super();
	}


	public Set getDefaultScoringLevels(Skill skill) {
		Set defaultScoringLevels = new HashSet();
		if (this.getCode().equals(SCORING_METHOD_NONE)) {

		} else if (this.getCode().equals(SCORING_METHOD_YES_NO)) {
			SkillScoringMethodLevel level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.yes");
			level.setLevelValue("y");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(75));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.no");
			level.setLevelValue("n");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(0));
			defaultScoringLevels.add(level);
		} else if (this.getCode().equals(SCORING_METHOD_LEVEL)) {
			SkillScoringMethodLevel level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.0");
			level.setLevelValue("0");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(0));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.1");
			level.setLevelValue("1");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(20));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.2");
			level.setLevelValue("2");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(40));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.3");
			level.setLevelValue("3");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(60));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.4");
			level.setLevelValue("4");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(80));
			defaultScoringLevels.add(level);

			level = new SkillScoringMethodLevel();
			level.setCaption("phrase.skill.level.5");
			level.setLevelValue("5");
			level.setSkill(skill);
			level.setSkillScoringMethod(this);
			level.setScore(new Integer(100));
			defaultScoringLevels.add(level);
		} else {
			throw new SystemException("Do not know how to handle scoring method: " + this.getCode());
		}

		return(defaultScoringLevels);
	}

	/**
	 * @return Returns the description.
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description The description to set.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return Returns the code.
	 */
	public String getCode() {
		return code;
	}
	/**
	 * @param code The code to set.
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return Returns the voided.
	 */
	public boolean getVoided() {
		return voided;
	}
	/**
	 * @param voided The voided to set.
	 */
	public void setVoided(boolean voided) {
		this.voided = voided;
	}
}
